import { Empty } from 'antd'
import { ITableData } from './types'

export const useFormDelivery = ({
  SupplierCYOption,
  getSupList,
}: {
  SupplierCYOption: IOptionItem[]
  getSupList: (newVal: string) => void
}): IItemArray[] => {
  return [
    {
      name: 'estimatedArrivalTime',
      label: '预计到货时间',
      type: 'DatePicker',
      placeholder: '请选择预计到货时间',
      rules: [
        {
          required: true,
          message: '请选择预计到货时间',
        },
      ],
    },
    {
      name: 'transporterId',
      label: '承运商',
      type: 'Select',
      option: SupplierCYOption,
      config: {
        suffixIcon: null,
        showSearch: true,
        optionFilterProp: 'label',
        filterOption: false,
        onSearch: getSupList,
        onClear: getSupList,
        notFoundContent: <Empty description="请输入内容搜索" image={Empty.PRESENTED_IMAGE_SIMPLE} />,
      },
    },
    {
      name: 'transportSn',
      label: '承运单号',
      type: 'Input',
    },
    {
      name: 'contactInfo',
      label: '联系方式',
      type: 'Input',
    },
    {
      name: 'driverName',
      label: '司机姓名',
      type: 'Input',
    },
    {
      name: 'license',
      label: '车牌号',
      type: 'Input',
    },
  ]
}

export const useFormViewDelivery = ({ CurrentInfo }: { CurrentInfo: Record<string, any> }): IItemArray[] => {
  return [
    {
      label: '预计到货时间',
      type: 'Custom',
      slot: CurrentInfo.estimatedArrivalTime || '-',
    },
    {
      label: '承运商',
      type: 'Custom',
      slot: CurrentInfo.transporter || '-',
    },
    {
      label: '承运单号',
      type: 'Custom',
      slot: CurrentInfo.transportSn || '-',
    },
    {
      label: '联系方式',
      type: 'Custom',
      slot: CurrentInfo.contactInfo || '-',
    },
    {
      label: '司机姓名',
      type: 'Custom',
      slot: CurrentInfo.driverName || '-',
    },
    {
      label: '车牌号',
      type: 'Custom',
      slot: CurrentInfo.license || '-',
    },
  ]
}
